package cnam.smb215.findfriends;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;

public class SplashScreenActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splash_screen);

		Handler handler = new Handler();
		SharedPreferences sharedPreferences = getSharedPreferences(Globals.FILE_NAME_PREF, MODE_PRIVATE);
		
		boolean isFirstRun = sharedPreferences.getBoolean(Globals.PREF_FIRST_RUN, true);

		if(isFirstRun) {
			handler.postDelayed(new Runnable() {
				public void run() {
					Intent myIntent = new Intent(SplashScreenActivity.this, RegistrationActivity.class);
					myIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
					SplashScreenActivity.this.startActivity(myIntent);
				}
			}, Globals.SPLASH_SCREEN_DELAY);
		}
		else {
			handler.postDelayed(new Runnable() {
				public void run() {
					Intent myIntent = new Intent(SplashScreenActivity.this, MainActivity.class);
					myIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
					SplashScreenActivity.this.startActivity(myIntent);
				}
			}, Globals.SPLASH_SCREEN_DELAY);
		}
	}
}
